package com.eks.order.filter;

import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

/**
 * dubbo调用拦截器, 拦截所有dubbo接口，并把租户ID、影院ID作为参数注入到dubbo的RpcContext.getContext()中
 *
 * @author chenfenghai
 * @date 2019/05/13
 */
@Slf4j
@Activate(group = CommonConstants.PROVIDER, order = -20000)
public class RpcContextProviderFilter implements Filter {

    /**
     * Make sure call invoker.invoke() in your implementation.
     *
     * @param invoker
     * @param invocation
     */
    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        log.info("Order Provider 1");
        Result result = invoker.invoke(invocation);
        log.info("Order Provider 2");
        return result;
    }
}